<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCrmWorkSignTable extends Migration
{
    /**
     * Run the migrations.
     * 打卡表
     * @return void
     */
    public function up()
    {
        //
        Schema::create('crm_work_sign', function (Blueprint $table) {
            $table->engine='MyISAM';
            $table->comment='打卡表';
            $table->increments('id')->unsigned()->comment('自动增长主键');
            $table->integer('crm_uid')->unsigned()->default(0)->index('crm_uid')->comment('crm uid');
            $table->timestamp('sign_in_morning')->nullable()->comment('早上签到');
            $table->timestamp('sign_out_morning')->nullable()->comment('早上签退');
            $table->timestamp('sign_in_afternoon')->nullable()->comment('下午签到');
            $table->timestamp('sign_out_afternoon')->nullable()->comment('下午签退');
            $table->timestamp('sign_in_night')->nullable()->comment('晚上签到');
            $table->timestamp('sign_out_night')->nullable()->comment('晚上签退');
            $table->timestamps();
            $table->index('create_time');
            $table->unique(['crm_uid','created_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::drop('crm_work_sign');
    }
}
